Gopher Proxy
gopher.icu:70 gopher.icu:70/0/phlog/Computing/I-know-vi(m)--Show-me!.md
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# I know vi(m) - Show me!
If you've come to use vi(m) from a GUI editor then sadly, you come
with baggage. Even if you didn't, you may have started your vim
journey with vimtutor which, I believe, sets you firmly off on the
wrong path.
I know this because, I too came with baggage and did the vimtutor
on a few occasions. Due to this, it was many years after I started
to use vim that I came to understand the fundamental power of a
modal editor.
It was only after I began to look into ed that the penny finally
dropped for me.
## hjkl
Unfortunately, being able to scroll around the screen like in a GUI
text editor doesn't point you to the holy grail that is the command
language which underpins ed, and subsequently vi(m).
A typical editing session would involve lots of scrolling around
and hitting the delete/x key. Maybe you knew how to yank something,
maybe you knew how to paste something but, for the most part, your
editing is all hjkl, deleting and retyping.
You can't scroll around in ed so, how do you say delete a particular
line? The same exact way you can in vi(m).
Every command can be prefixed with line number # or range #,#.
Enable line numbers, :set nu, to make life easier.
## An example edit session
'''
1 This line I want.
2 This line I don't.
3 This line I also don't.
4 I want this one, but I want it at the top of the file.
5 I misspelled bananaannnnna.
'''
So there are two lines you don't want:
hjkl to each line and dd
...
Or, specify the line or range you want to delete :2,3d
You want to correct that spelling error:
hjkl to the beginning of the word cw and retype
...
Or, :5s/ban.*/banana\./
You want to move that last line to the first:
hjkl to the line and dd hjkl to the top line and P
...
Or, :4d :1 P
You take the [blue pill][0], the story ends... You take the
[red pill][1], you stay in Wonderland, and I show you how deep the
rabbit hole goes.
[0]: gopher://gopher.icu/1/phlog
[1]: gopher://gopher.icu/9/files/edtut-advanced.pdf
you're on gopher.icu^70/0/phlog/Computing/I-know-vi(m)--Show-me!.md
back link is gopher.icu:70